//
//  XXJTabBarController.m
//  gosh
//
//  Created by 许小军 on 16/9/22.
//  Copyright © 2016年 wyzc. All rights reserved.
//

#import "XXJTabBarController.h"
#import "EssenceViewController.h"
#import "NewViewController.h"
#import "FrendTendViewController.h"
#import "MeViewController.h"
#import "PunlishViewController.h"
#import "XXJTabBar.h"
@interface XXJTabBarController ()

@end

@implementation XXJTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpChildView];
    
    [self setChildTitle];
    
    [self changeTabBar];
}

+(void)load
{
    UITabBarItem * item=[UITabBarItem appearanceWhenContainedIn:self, nil];
    
    [item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateSelected];
}

-(void)changeTabBar
{
    XXJTabBar * tabBar=[[XXJTabBar alloc]init];
    
    [self setValue:tabBar forKey:@"tabBar"];
}

-(void)setUpChildView
{
    EssenceViewController * essence=[[EssenceViewController alloc]init];
    UINavigationController * Navessence=[[UINavigationController alloc]initWithRootViewController:essence];
    [self addChildViewController:Navessence];
    
    
    
    NewViewController * new=[[NewViewController alloc]init];
    UINavigationController *  navNew=[[UINavigationController alloc]initWithRootViewController:new];
    [self addChildViewController:navNew];
    
//    PunlishViewController * publish=[[PunlishViewController alloc]init];
//    UINavigationController * navPublish=[[UINavigationController alloc]initWithRootViewController:publish];
//    [self addChildViewController:navPublish];
    
    FrendTendViewController * frend=[[FrendTendViewController alloc]init];
    UINavigationController * navFrend=[[UINavigationController alloc]initWithRootViewController:frend];
    [self addChildViewController:navFrend];
    
    
    UIStoryboard * storyboard=[UIStoryboard storyboardWithName:NSStringFromClass([MeViewController class]) bundle:nil];
    MeViewController * me=[storyboard instantiateInitialViewController];
    //MeViewController * me=[[MeViewController alloc]init];
    UINavigationController * navMe=[[UINavigationController alloc]initWithRootViewController:me];
    [self addChildViewController:navMe];
    
    
    
    
    
    
}

-(void)setChildTitle
{
    UINavigationController * nav0=self.childViewControllers[0];
    nav0.tabBarItem.title=@"精华";
    nav0.tabBarItem.image=[UIImage imageNamed:@"tabBar_essence_icon"];
    nav0.tabBarItem.selectedImage=[[UIImage imageNamed:@"tabBar_essence_click_icon"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    
    
    UINavigationController * nav1=self.childViewControllers[1];
    nav1.tabBarItem.title=@"新帖";
    nav1.tabBarItem.image=[UIImage imageNamed:@"tabBar_new_icon"];
    nav1.tabBarItem.selectedImage=[[UIImage imageNamed:@"tabBar_new_click_icon"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    
    
//    PunlishViewController * pub=self.childViewControllers[2];
//    pub.tabBarItem.image=[UIImage imageNamed:@"tabBar_publish_icon"];
//    pub.tabBarItem.selectedImage=[[UIImage imageNamed:@"tabBar_publish_click_icon"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UINavigationController * nav2=self.childViewControllers[2];
    nav2.tabBarItem.title=@"关注";
    nav2.tabBarItem.image=[UIImage imageNamed:@"tabBar_friendTrends_icon"];
    nav2.tabBarItem.selectedImage=[[UIImage imageNamed:@"tabBar_friendTrends_click_icon"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
    UINavigationController * nav3=self.childViewControllers[3];
    nav3.tabBarItem.title=@"我";
    nav3.tabBarItem.image=[UIImage imageNamed:@"tabBar_me_icon"];
    nav3.tabBarItem.selectedImage=[[UIImage imageNamed:@"tabBar_me_click_icon"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
